package com.kingschan.jeasytag.core.parse.properties.impl;

import java.lang.reflect.Field;
import com.kingschan.jeasytag.core.annotations.tag.*;
import com.kingschan.jeasytag.core.parse.properties.PropertiesParse;
/**
 * EventFieldParseImpl
 * @author kingschan
 *date:2013-7-11
 */
public class EventFieldParseImpl implements PropertiesParse {

	@Override
	public String parse(Field f, Object obj) throws Exception {
		EventField e = f.getAnnotation(EventField.class);
		String tempstr = "";
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < e.args().length; i++) {
			tempstr+=e.args()[i];
			if (i!=e.args().length-1) {
				tempstr+=",";
			}
		}
			sb.append(f.getName()).append(":function(").append(tempstr).append("){")
			.append(obj.toString()).append("}");
		return sb.toString();
	}
		

}
